{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'refresh_token': '25.66564968853e6670095da64aa0374cdb.315360000.1918900363.282335-22870235', 'expires_in': 2592000, 'session_key': '9mzdDAXbMN5sY0QM1ZYff47lciPGrzPvYlI1NJEhSILhq+atktM2vgy1UYSQP6kQb3xexaf8qrgxkSvcgpvY8xCOtM+giw==', 'access_token': '24.70982ccb47295d59da063504d42520f8.2592000.1606132363.282335-22870235', 'scope': 'public brain_all_scope vis-faceverify_faceverify_h5-face-liveness vis-faceverify_FACE_V3 vis-faceverify_idl_face_merge vis-faceverify_FACE_EFFECT vis-faceverify_face_feature_sdk wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理 smartapp_component', 'session_secret': 'fa638657e185f726107a946c463c5e9b'}\n"
     ]
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "import requests \n",
    "\n",
    "# client_id 为官网获取的AK， client_secret 为官网获取的SK\n",
    "host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=uWOtZpqnthUUOImfGfs35Spq&client_secret=euw7D4MlsZDDEl5RfofqXLgilwiT43Sn'\n",
    "response = requests.get(host)\n",
    "if response:\n",
    "    print(response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'error_code': 0, 'error_msg': 'SUCCESS', 'log_id': 4500120100179, 'timestamp': 1603540782, 'cached': 0, 'result': {'face_num': 1, 'face_list': [{'face_token': 'b99fb0aa29ec35acd084875fa63f6f0d', 'location': {'left': 429.54, 'top': 483.49, 'width': 351, 'height': 337, 'rotation': -22}, 'face_probability': 1, 'angle': {'yaw': 36.24, 'pitch': 8.93, 'roll': -22.37}, 'face_shape': {'type': 'round', 'probability': 0.56}, 'face_type': {'type': 'human', 'probability': 0.99}}]}}\n"
     ]
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "\n",
    "'''\n",
    "人脸检测与属性分析\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/face/v3/detect\"\n",
    "\n",
    "params = \"{\\\"image\\\":\\\"https://gitee.com/li_man_qi/api_start/raw/master/images/dl.jpg\\\",\\\"image_type\\\":\\\"URL\\\",\\\"face_field\\\":\\\"faceshape,facetype\\\"}\"\n",
    "access_token = '24.70982ccb47295d59da063504d42520f8.2592000.1606132363.282335-22870235' #上面提取\n",
    "request_url = request_url + \"?access_token=\" + access_token\n",
    "headers = {'content-type': 'application/json'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "if response:\n",
    "    print (response.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 人脸相似度对比集合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'refresh_token': '25.c61aef2ff88582cab1f763dc672dc4e8.315360000.1918901027.282335-22870235', 'expires_in': 2592000, 'session_key': '9mzdWEDZVdo4AgYTWgDog6cI/aQwWcV6kVkv+awx9uQgR78w7S1hCZsaNYWGbk2pfhOOloIQzp4t/y0aRWdeqMPSw1Y0IA==', 'access_token': '24.c070a73d2b6c99f11d8c245ce898d69b.2592000.1606133027.282335-22870235', 'scope': 'public brain_all_scope vis-faceverify_faceverify_h5-face-liveness vis-faceverify_FACE_V3 vis-faceverify_idl_face_merge vis-faceverify_FACE_EFFECT vis-faceverify_face_feature_sdk wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理 smartapp_component', 'session_secret': '28492da9bb9e4f90d85b101a19e9e3b3'}\n"
     ]
    }
   ],
   "source": [
    " # encoding:utf-8\n",
    "import requests \n",
    "\n",
    "# client_id 为官网获取的AK， client_secret 为官网获取的SK\n",
    "host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=uWOtZpqnthUUOImfGfs35Spq&client_secret=euw7D4MlsZDDEl5RfofqXLgilwiT43Sn'\n",
    "response = requests.get(host)\n",
    "if response:\n",
    "    print(response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'error_code': 0, 'error_msg': 'SUCCESS', 'log_id': 7565101201557, 'timestamp': 1603541474, 'cached': 0, 'result': {'score': 50.63898468, 'face_list': [{'face_token': 'b99fb0aa29ec35acd084875fa63f6f0d'}, {'face_token': 'fd975febce522f4e320484e55d02493f'}]}}\n"
     ]
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "\n",
    "'''\n",
    "人脸对比\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/face/v3/match\"\n",
    "\n",
    "params = \"[{\\\"image\\\": \\\"https://gitee.com/li_man_qi/api_start/raw/master/images/dl.jpg\\\", \\\"image_type\\\": \\\"URL\\\", \\\"face_type\\\": \\\"LIVE\\\", \\\"quality_control\\\": \\\"LOW\\\"},{\\\"image\\\": \\\"https://gitee.com/li_man_qi/api_start/raw/master/images/zxc.jpg\\\", \\\"image_type\\\": \\\"URL\\\", \\\"face_type\\\": \\\"IDCARD\\\", \\\"quality_control\\\": \\\"LOW\\\"}]\"\n",
    "access_token ='24.4f60fbbed87533d24cde68282e9fa559.2592000.1605715791.282335-22845547'\n",
    "request_url = request_url + \"?access_token=\" + access_token\n",
    "headers = {'content-type': 'application/json'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "if response:\n",
    "    print (response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
